import os

# 1、打开文件
# file = open("test.txt", encoding='utf-8')
path = os.getcwd()
file = open(path + '/test.txt', mode='r', encoding='utf-8')
# file = open("E:\\Python\\code\\pycharm\\python_base\\lesson07\\test.txt", encoding='utf-8')
# file = open("../test1.txt", mode='r', encoding='utf-8')

# 2、读取文件
# content = file.read()
# content = file.read(10)  # 指定读几个字符
# content = file.readline()  # 读一行
content = file.readlines()  # 按行读，存到列表里
print(content)
# 3、关闭文件
file.close()
